import sympy as sy

t = sy.symbols('t')
y = t * (sy.Heaviside(t) - sy.Heaviside(t - 1))  # 原始信号
y1 = y.subs(t, -2 * t + 3)
y2 = y.diff(t)
y3 = y.integrate(t)
y4 = y.integrate(t, (t, 0, 1))
print('波形变换 f(-2t+3)：', sy.simplify(y1))
print('求导：', sy.simplify(y2))
print('不定积分：', sy.simplify(y3))
print('定积分：', y4)
print( sy.pretty(sy.simplify(y3)))
'''绘图'''
p0 = sy.plot(y, (t, -1, 2), title='f(t)', xlabel='t', show=False)
p1 = sy.plot(y1, (t, -1, 2), title='f(-2t+3)', xlabel='t', show=False)
p2 = sy.plot(y2, (t, -1, 2), title='f’(t)', xlabel='t', show=False)
p3 = sy.plot(y3, (t, -1, 2), title='∫f(t)dt', xlabel='t', show=False)
sy.plotting.PlotGrid(2, 2, p0, p1, p2, p3)
